package com.candy.databasedocuments.service;

import com.candy.databasedocuments.entity.DatabaseConfig;
import com.candy.databasedocuments.entity.Table;
import org.springframework.stereotype.Component;

import java.sql.Connection;
import java.util.List;

/**
 * @author suYanLong
 * @version 1.0
 * @date 2023/7/5 16:07
 * @Description 数据库配置 -> 数据库表结构数据
 */
@Component
public class DatabaseService {

    public List<Table> getTableInfos(DatabaseConfig databaseConfig) throws Exception {
        DatabaseConnect databaseConnect = DatabaseConnectFactory.getDatabaseConnect(databaseConfig.getDbAttr().getDbType().getDbType());
        databaseConnect.getConnectInfo(databaseConfig);
        Connection connection = databaseConnect.connectDatabase(databaseConfig);
        return databaseConnect.getTableBaseInfoList(connection);
    }

}
